package main;

/**
 *
 * @author Ramunas
 */
import java.util.LinkedList;
import javax.swing.table.AbstractTableModel;
import processes.Process;

public class ProcTable extends AbstractTableModel{
    private final int COLUMNS = 3;
    private final int PROCESS = 0;
    private final int STATE = 1;
    private final int PROGRESS = 2;
    private LinkedList<Process> list;
    private String[] columnName = new String[COLUMNS]; 
    
    public ProcTable(){
        this.columnName[PROCESS] = "Process";
        this.columnName[STATE] = "State";
        this.columnName[PROGRESS] = "Progress";
        this.list = Lists.getProcesses();
    }
    
    @Override
    public String getColumnName(int index){
        return columnName[index];
    }
    
    @Override
    public int getRowCount() {
        return list.size();       
    }

    @Override
    public int getColumnCount() {
        return COLUMNS;
    }

    @Override
    public String getValueAt(int row, int column) {
        String result;
        switch(column){
            case PROCESS:  result = list.get(row).getName();
                           break;
            case STATE:    result = list.get(row).getState();
                           break;
            case PROGRESS: result = list.get(row).getProgress();
                           break;
            default:       result = "false";
                           break;
        }
        
        return result;
    }
}
